package com.luge.base;

import android.app.Activity;
import android.os.Bundle;

import com.luge.utils.Helper;

public abstract class BaseActivity extends Activity {
	private boolean init = true;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Helper.log(this.getClass().getName() + "-->onCreate()");
		if (savedInstanceState != null) {
			Base.key = savedInstanceState.getString("KEY");
		}
		init();
	}

	@Override
	protected void onSaveInstanceState(Bundle outState) {
		super.onSaveInstanceState(outState);
		Helper.log(this.getClass().getName() + "-->onSaveInstanceState()");
		if (Base.key != null) {
			outState.putString("KEY", Base.key);
		}
	}

	protected abstract void init();

	protected abstract void main();

	@Override
	protected void onStart() {
		super.onStart();
		if (init) {
			main();
			init = false;
		}
		Helper.log(this.getClass().getName() + "-->onStart()");
	}

	@Override
	protected void onResume() {
		super.onResume();
		Helper.log(this.getClass().getName() + "-->onResume()");
	}

	@Override
	protected void onPause() {
		super.onPause();
		Helper.log(this.getClass().getName() + "-->onPause()");
	}

	@Override
	protected void onStop() {
		super.onStop();
		Helper.log(this.getClass().getName() + "-->onStop()");
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		Helper.log(this.getClass().getName() + "-->onDestroy()");
	}
}
